﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using SGCG.Helpers;

namespace SGCG.Model
{
    public class MirrorTransform : ITransform
    {
        private readonly Point basePoint, direction;

        public MirrorTransform(Point basePoint, Point direction)
        {
            this.basePoint = basePoint;
            this.direction = direction;
        }

        public Point Transform(Point point)
        {
            Point A = point.Subtract(basePoint);
            Point A1 = A.Project(direction);
            return basePoint.Add(A1).Add(A1).Subtract(A);
        }

        public void Transform(double angleInit, double angleSpan, out double newAngleInit, out double newAngleSpan)
        {
            newAngleSpan = angleSpan;

            double dirAngle = Math.Atan2(direction.Y, direction.X);
            newAngleInit = ((2 * dirAngle - angleInit - angleSpan) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
        }

        public event TransformChangedEventHandler TransformChanged
        {
            add { }
            remove { }
        }

    }

}
